package com.yhb.channel.impl.Scalable;

import com.yhb.channel.dao.Scalable.ScalableChannelBoundRelationshipMapper;
import com.yhb.channel.impl.Scalable.http.ScalableHttpClient;
import com.yhb.channel.provider.ChannelBaseService;
import com.yhb.channel.utils.ChannelLogger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

@Service
public class ScalableChannelFactory {
    public static final String CHANNEL_BASE_NAME = "第三方通道";

    @Autowired
    private ChannelBaseService channelBaseService;

    @Autowired
    private ScalableHttpClient httpClient;

    @Autowired
    private ScalableChannelBoundRelationshipMapper db;

    /**
     * 根据子通道编号生成子通道
     * @param channelCode 子通道编号
     * @return 北京畅捷子通道对象
     */
    public ScalableChannel getSubChannel(String channelCode) {
        ChannelLogger logger = new ChannelLogger(CHANNEL_BASE_NAME + '-' + channelCode,
                ScalableException.class, channelBaseService.iUtilProvider);
        return new ScalableChannel(channelCode, channelBaseService, httpClient, db, logger);
    }
}
